﻿using System.Collections.Generic;
using PgBirdie.Core.Model.Database.AccessControl;
using PgBirdie.Core.Model.Database.Data;
using PgBirdie.Core.Model.Database.Structure.Constraint;
using PgBirdie.Core.Model.Database.Structure.Index;

namespace PgBirdie.Core.Model.Database.Structure
{
    public class PgTable : PgDbObject, IPgOwner, IPgPrivileges
    {
        public PgSchema Schema { get; set; }
        public IDictionary<string, PgColumn> Columns { get; set; }

        public PgPrimaryKey PrimaryKey { get; set; }
        public IDictionary<string, PgUniqueKey> UniqueKeys { get; set; }
        public IDictionary<string, PgForeignKey> ForeignKeys { get; set; }

        public IDictionary<string, PgIndex> Indexes { get; set; }

        public IDictionary<string, PgCheck> Checks { get; set; }

        /// <summary>
        /// Key = primary key.
        /// </summary>
        public IDictionary<string, PgDataRow> DataRows { get; set; }

        public PgOwner Owner { get; set; }
        public IDictionary<string, PgPrivilege> Privileges { get; set; }

        public bool IsUnlogged { get; set; }

        public PgTable ()
        {
            Columns = new Dictionary<string, PgColumn>();
            UniqueKeys = new Dictionary<string, PgUniqueKey>();
            ForeignKeys = new Dictionary<string, PgForeignKey>();
            Indexes = new Dictionary<string, PgIndex>();
            Checks = new Dictionary<string, PgCheck>();
            DataRows = new Dictionary<string, PgDataRow>();
            Privileges = new Dictionary<string, PgPrivilege>();
        }
    }
}